
" echo "loading c project common conf"

" reset project ctags and cscope database for project
function! ResetProjectDatabase()
    set notagrelative
    set tags=""
    cscope kill -1
endfunction

" OmniCppComplete
let OmniCpp_NamespaceSearch = 0
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 0
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 0 " autocomplete after ::
let OmniCpp_DefaultNamespaces = []
" set completeopt=menuone,menu,longest,preview
set completeopt=menuone,menu,longest
autocmd FileType c set omnifunc=omni#cpp#complete#Main
imap <silent> <F2> <C-X><C-O>

" cscope
" 0 or s: Find this C symbol
" 1 or g: Find this definition
" 2 or d: Find functions called by this function
" 3 or c: Find functions calling this function
" 4 or t: Find this text string
" 6 or e: Find this egrep pattern
" 7 or f: Find this file
" 8 or i: Find files #including this file
set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <silent> <Leader>ss :cscope find s <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <silent> <Leader>sg :cscope find g <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <silent> <Leader>sd :cscope find d <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <silent> <Leader>sc :cscope find c <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <silent> <Leader>st :cscope find t <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <silent> <Leader>se :cscope find e <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <silent> <Leader>sf :cscope find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR>
" nmap <silent> <Leader>si :cscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR>
nmap <silent> <Leader>si :cscope find i <C-R>=expand("<cfile>")<CR><CR>:copen<CR>
